package com.example.wlzz.service.serviceImpl;

import com.example.wlzz.entity.HightSchool;
import com.example.wlzz.repository.mapper.ExcelMajorMapper;
import com.example.wlzz.repository.HightSchoolRepository;
import com.example.wlzz.service.SchoolService;
import com.example.wlzz.vo.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service
public class SchoolServiceImpl implements SchoolService {
    @Autowired
    private HightSchoolRepository hightSchoolRepository;
    @Override
    public PageVO findByHightSchool(Pageable pageable) {
        PageRequest request =  PageRequest.of(pageable.getPageNumber(),pageable.getPageSize());
        Page<HightSchool> hightSchoolPage = hightSchoolRepository.findAll(request);
        PageVO pageVO = new PageVO();
        pageVO.setCurrentPage(pageable.getPageNumber());
        pageVO.setDataList(hightSchoolPage.getContent());
        pageVO.setSize(pageable.getPageSize());
        pageVO.setTotalPage(hightSchoolPage.getTotalPages());
        return pageVO;
    }
}
